<?php
/**
 * 配置控制器
 * Date: 2025/09/10
 */

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\BaseController;
use App\Services\Admin\ConfigService;
use Illuminate\Http\Request;

class ConfigController extends BaseController
{
    /**
     * 配置信息
     * @date 2025/09/22
     * @return \Illuminate\Http\JsonResponse
     */
    public function info()
    {
        return (new ConfigService())->info();
    }

    /**
     * 配置详情
     * @date 2025/09/11
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function detail(Request $request)
    {
        $type = $request->input('type', '');
        if (empty($type)) {
            return $this->failed('配置类型不能为空');
        }
        return (new ConfigService())->detail($type);
    }

    /**
     * 配置更新
     * @date 2025/09/11
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function update(Request $request)
    {
        $params = $request->input();
        if (!isset($params['type']) || empty($params['type'])) {
            return $this->failed('配置类型不能为空');
        }
        return (new ConfigService())->update($params);
    }
}
